The following example demonstrates how to create a custom data template that will be used in the footers of the first-level groups to display the results of various statistical functions.

XAML
Copy Code
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
  <Grid.Resources>
    <xcdg:DataGridCollectionViewSource x:Key="cvs_orderdetails"
                                       Source="{Binding Source={x:Static Application.Current},
                                                        Path=OrderDetails}"> 
    <xcdg:DataGridCollectionViewSource.StatFunctions>
       <xcdg:CountFunction ResultPropertyName="orderid_count"
                           SourcePropertyName="OrderID"/>
       <xcdg:SumFunction ResultPropertyName="unitprice_sum"
                         SourcePropertyName="UnitPrice"/>
       <xcdg:AverageFunction ResultPropertyName="unitprice_average"
                             SourcePropertyName="UnitPrice"/>
       <xcdg:SumFunction ResultPropertyName="quantity_sum"
                         SourcePropertyName="Quantity"/>
     </xcdg:DataGridCollectionViewSource.StatFunctions>       
      <xcdg:DataGridCollectionViewSource.GroupDescriptions>
        <xcdg:DataGridGroupDescription PropertyName="ProductID"/>
      </xcdg:DataGridCollectionViewSource.GroupDescriptions>
    </xcdg:DataGridCollectionViewSource>
   <xcdg:StatResultConverter x:Key="valueConverter"/>
  </Grid.Resources>
  <xcdg:DataGridControl x:Name="OrderDetailsGrid"
                        ItemsSource="{Binding Source={StaticResource cvs_orderdetails}}">
    <xcdg:DataGridControl.DefaultGroupConfiguration>
      <xcdg:GroupConfiguration>
        <xcdg:GroupConfiguration.Footers>
          <xcdg:GroupHeaderFooterItemTemplate VisibleWhenCollapsed="True">
            <DataTemplate>
              <Border Background="#999999"
                      BorderBrush="LightBlue"
                      BorderThickness="3"
                      Margin="5" >
                <Grid>
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                  </Grid.ColumnDefinitions>
                  <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                  </Grid.RowDefinitions>
                  <TextBlock Text="Total Orders: " Grid.Row="0" Grid.Column="0"/>
                   <TextBlock Text="{Binding RelativeSource={RelativeSource Self},
                                             Path=(xcdg:DataGridControl.StatContext).orderid_count}"
                              Grid.Row="0" Grid.Column="1"/>                    
                    <TextBlock Text="Total Quantity Sold: " Grid.Row="1" Grid.Column="0"/>
                   <TextBlock Text="{Binding RelativeSource={RelativeSource Self},
                                   Path=(xcdg:DataGridControl.StatContext).quantity_sum}"
                                   Grid.Row="1" Grid.Column="1"/>  
                    <TextBlock Text="Total Sales: " Grid.Row="2" Grid.Column="0"/>
                   <TextBlock Text="{Binding RelativeSource={RelativeSource Self},
                                             Path=(xcdg:DataGridControl.StatContext).unitprice_sum}"
                              Grid.Row="2" Grid.Column="1"/>  
                    <TextBlock Text="Average Unit Price: " Grid.Row="3" Grid.Column="0"/>
                   <TextBlock Text="{Binding RelativeSource={RelativeSource Self},
                                             Path=(xcdg:DataGridControl.StatContext).unitprice_average,
                                             Converter={StaticResource valueConverter},
                                             ConverterParameter=f2}"
                              Grid.Row="3" Grid.Column="1"/>         
                  </Grid>
                </Border> 
              </DataTemplate>  
            </xcdg:GroupHeaderFooterItemTemplate>
          </xcdg:GroupConfiguration.Footers>
        </xcdg:GroupConfiguration>
      </xcdg:DataGridControl.DefaultGroupConfiguration>
      <xcdg:DataGridControl.View>
        <xcdg:CardView AllowCardResize="True"/>
      </xcdg:DataGridControl.View>
    </xcdg:DataGridControl>
  </Grid>